<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tzhang" uri="http://www.elife.com/qingsheng" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>生成订单</title>
    <link href="/pharmacy/css/orderpublic.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="/pharmacy/js/jquery_cart.js"></script>
    <link rel="stylesheet" type="text/css" href="/pharmacy/css/orderbase.css"/>
    <link rel="stylesheet" type="text/css" href="/pharmacy/css/checkOut.css" />
</head>
<body>
<div class="banner_red_top">
</div>
<%--收货地址body部分开始--%>
<div class="border_top_cart">
    <script type="text/javascript">
        var checkoutConfig={
            addressMatch:'common',
            addressMatchVarName:'data',
            hasPresales:false,
            hasBigTv:false,
            hasAir:false,
            hasScales:false,
            hasGiftcard:false,
            totalPrice:244.00,
            postage:10,//运费
            postFree:true,//活动是否免邮了
            bcPrice:150,//计算界值
            activityDiscountMoney:0.00,//活动优惠
            showCouponBox:0,
            invoice:{
                NA:"0",
                personal:"1",
                company:"2",
                electronic:"4"
            }
        };
        var miniCartDisable=true;
    </script>
    <div class="container">
        <div class="checkout-box">
            <form id="checkoutForm" action="" method="post">
                <div class="checkout-box-bd">
                    <input type="hidden" name="Checkout[addressState]" id="addrState" value="0">
                    <!-- 收货地址 -->
                    <div class="xm-box">
                        <div class="box-hd ">
                            <h2 class="title">收货地址</h2>
                        </div>
                        <div class="box-bd">
                            <div class="clearfix xm-address-list" id="checkoutAddrList">
                                <c:forEach var="addressList" items="${addressList}">
                                    <dl class="item" id="addressId" value="${addressList.id}">
                                        <p id="value" style="display: none">${addressList.id}</p>
                                        <p class="Consignee">${addressList.receiverName}</p>
                                        <p class="tel itemTel">${addressList.receiverPhone}</p>
                                        <p class="itemRegion">${addressList.receiverProvince} ${addressList.receiverCity} ${addressList.receiverDistrict}</p>
                                        <p class="itemStreet">${addressList.receiverAddress}(${addressList.receiverZip})</p>
                                        <span class="edit-btn J_editAddr">编辑</span>
                                        <dd style="display:none">
                                            <input type="radio" name="Checkout[address]" class="addressId"
                                                   value="10140916720030323">
                                        </dd>
                                    </dl>
                                </c:forEach>
                                <div class="item use-new-addr" id="J_useNewAddr" data-state="off">
                                    <span class="iconfont icon-add"><img src="/pharmacy/images/add_cart.png"/></span>
                                    使用新地址
                                </div>
                            </div>
                            <input type="hidden" name="newAddress[type]" id="newType" value="common">
                            <input type="hidden" name="newAddress[consignee]" id="newConsignee">
                            <input type="hidden" name="newAddress[province]" id="newProvince">
                            <input type="hidden" name="newAddress[city]" id="newCity">
                            <input type="hidden" name="newAddress[district]" id="newCounty">
                            <input type="hidden" name="newAddress[address]" id="newStreet">
                            <input type="hidden" name="newAddress[zipcode]" id="newZipcode">
                            <input type="hidden" name="newAddress[tel]" id="newTel">
                            <input type="hidden" name="newAddress[tag_name]" id="newTag">
                            <%--&lt;!&ndash;点击弹出新增/收货地址界面start&ndash;&gt;--%>
                            <div class="xm-edit-addr-box" id="J_editAddrBox">
                                <form action="">
                                    <div class="bd">
                                        <div class="item">
                                            <label>收货人姓名<span>*</span></label>
                                            <input type="text" name="userAddress[consignee]" id="Consignee"
                                                   class="input" placeholder="收货人姓名" maxlength="15" autocomplete='off'>
                                            <p class="tip-msg tipMsg"></p>
                                        </div>
                                        <div class="item">
                                            <label>联系电话<span>*</span></label>
                                            <input type="text" name="userAddress[tel]" class="input" id="Telephone"
                                                   placeholder="11位手机号" autocomplete='off'>
                                            <p class="tel-modify-tip" id="telModifyTip"></p>
                                            <p class="tip-msg tipMsg"></p>
                                        </div>
                                        <div class="item">
                                            <label>地址<span>*</span></label>
                                            <select name="userAddress[province]" id="Provinces" class="select-1">
                                                <option>省份/自治区</option>
                                            </select>
                                            <select name="userAddress[city]" id="Citys" class="select-2" disabled>
                                                <option>城市/地区/自治州</option>
                                            </select>
                                            <select name="userAddress[county]" id="Countys" class="select-3" disabled>
                                                <option>区/县</option>
                                            </select>
                                            <textarea name="userAddress[street]" class="input-area" id="Street"
                                                      placeholder="路名或街道地址，门牌号"></textarea>
                                            <p class="tip-msg tipMsg"></p>
                                        </div>
                                        <div class="item">
                                            <label>邮政编码<span>*</span></label>
                                            <input type="text" name="userAddress[zipcode]" id="Zipcode" class="input"
                                                   placeholder="邮政编码" autocomplete='off'>
                                            <p class="zipcode-tip" id="zipcodeTip"></p>
                                            <p class="tip-msg tipMsg"></p>
                                        </div>
                                    </div>
                                    <div class="ft clearfix">
                                        <button type="button" class="btn btn-lineDake btn-small " id="J_editAddrCancel">
                                            取消
                                        </button>
                                        <button type="button" class="btn btn-primary  btn-small " id="J_editAddrOk"
                                                onclick="address()">保存
                                        </button>
                                    </div>
                                </form>
                            </div>
                            <%--&lt;!&ndash;点击弹出新增/收货地址界面end&ndash;&gt;--%>
                            <div class="xm-edit-addr-backdrop" id="J_editAddrBackdrop"></div>
                        </div>
                    </div>
                    <%--收货地址 END--%>
                    <div id="checkoutPayment">
                        <%--支付方式 --%>
                        <div class="xm-box">
                            <div class="box-hd ">
                                <h2 class="title">支付方式</h2>
                            </div>
                            <div class="box-bd">
                                <ul id="checkoutPaymentList" class="checkout-option-list clearfix J_optionList">
                                    <li class="item selected">
                                        <input type="radio" name="Checkout[pay_id]" checked="checked" value="1">
                                        <p>
                                            在线支付 <span></span>
                                        </p>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                <%--支付方式 END--%>
            <c:choose>
                <c:when test="${not empty cartsInfoList}">
                    <div class="checkout-box-ft">
                            <%--商品清单 --%>
                        <div id="checkoutGoodsList" class="checkout-goods-box">
                            <div class="xm-box">
                                <div class="box-hd">
                                    <h2 class="title">确认订单信息</h2>
                                </div>
                                <div class="box-bd">
                                    <dl class="checkout-goods-list">
                                        <dt class="clearfix">
                                            <span class="col col-1">商品名称</span>
                                            <span class="col col-2">购买价格</span>
                                            <span class="col col-3">购买数量</span>
                                            <span class="col col-4">小计（元）</span>
                                        </dt>
                                        <c:forEach var="cartsInfoList" items="${cartsInfoList}">
                                            <dl class="item clearfix">
                                                <div class="item-row">
                                                    <div class="col col-1">
                                                        <div class="g-pic">
                                                            <img src="/pharmacy/${cartsInfoList.goodImages}" width="40"
                                                                 height="40"/>
                                                        </div>
                                                        <div class="g-info">
                                                                ${cartsInfoList.goodName}
                                                        </div>
                                                    </div>
                                                    <div class="col col-2">${cartsInfoList.goodPrice}</div>
                                                    <div class="col col-3">${cartsInfoList.goodNum}</div>
                                                    <div class="col col-4">${tzhang:countMulti(cartsInfoList.goodPrice, cartsInfoList.goodNum)}
                                                    </div>
                                                </div>
                                            </dl>
                                        </c:forEach>
                                    </dl>
                                    <div class="checkout-count clearfix">
                                        <div class="checkout-price">
                                            <ul>
                                                <li>
                                                    订单总额：<span>${totalprice}</span>
                                                </li>
                                            </ul>
                                            <p class="checkout-total">应付总额：<span><strong
                                            >${totalprice}</strong>元</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                            <%--商品清单 END --%>
                        <input type="hidden" id="couponType" name="Checkout[couponsType]">
                        <input type="hidden" id="couponValue" name="Checkout[couponsValue]">
                        <div class="checkout-confirm">
                            <a href="/pharmacy/cart/showcart" class="btn btn-lineDakeLight btn-back-cart">返回购物车</a>
                            <input type="button" class="btn btn-primary"
                                   onclick="place(${orders.id})" value="立即下单"/>
                        </div>
                    </div>
                </c:when>

                <c:when test="${not empty goodDetail}">
                <div class="checkout-box-ft">
                    <%--商品清单 --%>
                    <div id="checkoutGoodsList" class="checkout-goods-box">
                        <div class="xm-box">
                            <div class="box-hd">
                                <h2 class="title">确认订单信息</h2>
                            </div>
                            <div class="box-bd">
                                <dl class="checkout-goods-list">
                                    <dt class="clearfix">
                                        <span class="col col-1">商品名称</span>
                                        <span class="col col-2">购买价格</span>
                                        <span class="col col-3">购买数量</span>
                                        <span class="col col-4">小计（元）</span>
                                    </dt>
                                    <dl class="item clearfix">
                                        <div class="item-row">
                                            <div class="col col-1">
                                                <div class="g-pic">
                                                    <img src="/pharmacy/${goodDetail.goodImages}" width="40"
                                                         height="40"/>
                                                </div>
                                                <div class="g-info">
                                                    <a href="#">
                                                        ${goodDetail.goodName} </a>
                                                </div>
                                            </div>
                                            <div class="col col-2">${goodDetail.goodPrice}</div>
                                            <div class="col col-3">${number}</div>
                                            <div class="col col-4">${price}</div>
                                        </div>
                                    </dl>
                                </dl>
                                <div class="checkout-count clearfix">
                                    <div class="checkout-price">
                                        <ul>
                                            <li>
                                                订单总额：<span>${price}</span>
                                            </li>
                                        </ul>
                                        <p class="checkout-total">应付总额：<span><strong
                                                id="price">${price}</strong>元</span></p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <%--商品清单 END --%>
                    <input type="hidden" id="couponType" name="Checkout[couponsType]">
                    <input type="hidden" id="couponValue" name="Checkout[couponsValue]">
                    <div class="checkout-confirm">
                        <a href="/pharmacy/cart/showcart" class="btn btn-lineDakeLight btn-back-cart">返回购物车</a>
                        <input type="button" class="btn btn-primary"
                               onclick="place(${orders.id})" value="立即下单" id="checkoutToPay"/>
                    </div>
                </div>
                </c:when>

                <c:when test="${not empty seckillGoodsVO}">
                    <div class="checkout-box-ft">
                            <%--商品清单 --%>
                        <div id="checkoutGoodsList" class="checkout-goods-box">
                            <div class="xm-box">
                                <div class="box-hd">
                                    <h2 class="title">确认订单信息</h2>
                                </div>
                                <div class="box-bd">
                                    <dl class="checkout-goods-list">
                                        <dt class="clearfix">
                                            <span class="col col-1">商品名称</span>
                                            <span class="col col-2">购买价格</span>
                                            <span class="col col-3">购买数量</span>
                                            <span class="col col-4">小计（元）</span>
                                        </dt>
                                        <dl class="item clearfix">
                                            <div class="item-row">
                                                <div class="col col-1">
                                                    <div class="g-pic">
                                                        <img src="/pharmacy/${seckillGoodsVO.goodImages}" width="40"
                                                             height="40"/>
                                                    </div>
                                                    <div class="g-info">
                                                        <a href="#">
                                                                ${seckillGoodsVO.goodName} </a>
                                                    </div>
                                                </div>
                                                <div class="col col-2">${seckillGoodsVO.goodPrice}</div>
                                                <div class="col col-3">1</div>
                                                <div class="col col-4">${seckillGoodsVO.goodPrice}</div>
                                            </div>
                                        </dl>
                                    </dl>
                                    <div class="checkout-count clearfix">
                                        <div class="checkout-price">
                                            <ul>
                                                <li>
                                                    订单总额：<span>${seckillGoodsVO.goodPrice}</span>
                                                </li>
                                            </ul>
                                            <p class="checkout-total">应付总额：<span><strong
                                            >${seckillGoodsVO.goodPrice}</strong>元</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                            <%--商品清单 END --%>
                        <input type="hidden" id="couponType" name="Checkout[couponsType]">
                        <input type="hidden" id="couponValue" name="Checkout[couponsValue]">
                        <div class="checkout-confirm">
                            <a href="/pharmacy/cart/showcart" class="btn btn-lineDakeLight btn-back-cart">返回购物车</a>
                            <input type="button" class="btn btn-primary"
                                   onclick="place(${orderId})" value="立即下单"/>
                        </div>
                    </div>
                </c:when>

            </c:choose>

            </form>
        </div>
        </form>
    </div>

    <script type="text/javascript" src="/pharmacy/js/base.min.js"></script>

    <script type="text/javascript" src="/pharmacy/js/address_all.js"></script>
    <script type="text/javascript" src="/pharmacy/js/checkout.min.js"></script>
</div>
</div>
<%--收货地址body部分结束--%>
<script src="/pharmacy/jquery/jquery-3.4.1.js"></script>
<script src="/pharmacy/js/unslider.min.js" type="text/javascript"></script>
</body>
<script>
    function address() {
        var receiverName =$('#Consignee').val()
        var receiverPhone =$('#Telephone').val();
        var receiverProvince=document.getElementById('Provinces').options[1].innerHTML;
        var receiverCity =document.getElementById('Citys').options[1].innerHTML;
        var receiverDistrict =document.getElementById('Countys').options[1].innerHTML;
        var receiverAddress =$('#Street').val();
        var receiverZip =$('#Zipcode').val();
        if(!(receiverName&&receiverPhone&&receiverProvince&&receiverCity&&receiverDistrict&&receiverAddress&&receiverZip))return -1;
        console.log(receiverProvince)
        console.log(receiverCity)
        console.log(receiverDistrict)
        $.post('address',{receiverName:receiverName,receiverPhone:receiverPhone,receiverProvince:receiverProvince,receiverCity:receiverCity,receiverDistrict:receiverDistrict,receiverAddress:receiverAddress,receiverZip:receiverZip},function (data) {
            if(data>0) layer.closeAll('iframe');
        })
    }
    function place(orderId) {
        var addressId=$(".selected")[0].getAttribute("value");
        console.log(addressId)
        window.location.href="/pharmacy/order/place?addressId="+addressId+"&orderId="+orderId
    }
</script>
</html>
